<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags"
                xmlns:component="http://java.sun.com/jsf/composite/component"
                template="/templates/template.xhtml">

    <ui:define name="title">开票工作台</ui:define>
    <ui:define name="content">
        <h:form id="workbenchForm">
            <div class="ui-g ui-fluid dashboard">
                <div class="ui-g-12 ui-md-12">
                    <p:tabView id="workflowTodoTaskTabView" scrollable="true">
                        <p:tab title="个人待办任务">
                            <div class="workbench-topbar clearfix"
                                 style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                                <p:toolbar>
                                    <f:facet name="right">
                                        <p:commandButton value="查询" icon="fa fa-search"
                                                         update="workflowTodoTaskDataTable"/>
                                        <p:commandButton value="重置" icon="fa fa-refresh"
                                                         actionListener="#{xhhBillWorkbenchBean.onResetTodoTask}"
                                                         process="@this"
                                                         update="todoTaskCategory todoTaskProcInstName todoTaskProcessInitialStartTime todoTaskProcessInitialEndTime"/>
                                    </f:facet>
                                </p:toolbar>
                            </div>
                            <div class="ui-fluid" style="padding-top: 40px;">
                                <div class="ui-g">
                                    <div class="ui-g-12">
                                        <div class="card ui-g-12">
                                            <p:panelGrid columns="4" layout="grid"
                                                         columnClasses="ui-grid-col-1,ui-grid-col-5,ui-grid-col-1,ui-grid-col-5"
                                                         styleClass="ui-panelgrid-blank"
                                                         style="border:0px none; background-color:transparent;text-align:center;">
                                                <p:outputLabel value="流程类型"/>
                                                <p:selectOneMenu id="todoTaskCategory"
                                                                 value="#{xhhBillWorkbenchBean.todoTaskSearchRequest.category}"
                                                                 filter="true"
                                                                 filterMatchMode="contains">
                                                    <f:selectItem itemLabel="请选择" itemValue=""
                                                                  noSelectionOption="true"/>
                                                    <f:selectItems
                                                            value="#{xhhBillWorkbenchBean.dictionaries[DictionaryCode.WORKFLOW_CATEGORY]}"
                                                            var="dic"
                                                            itemLabel="#{dic.name}" itemValue="#{dic.value1}"/>
                                                </p:selectOneMenu>

                                                <p:outputLabel value="流程标题"/>
                                                <p:inputText id="todoTaskProcInstName"
                                                             value="#{xhhBillWorkbenchBean.todoTaskSearchRequest.procInstName}"/>
                                                <p:outputLabel value="流程发起时间"/>
                                                <p:outputPanel>
                                                    <p:calendar id="todoTaskProcessInitialStartTime"
                                                                value="#{xhhBillWorkbenchBean.todoTaskSearchRequest.processInitialStartTime}"
                                                                styleClass="autoWidthCalendar"
                                                                locale="#{constants:get('LOCALE')}"
                                                                timeZone="#{constants:get('TIME_ZONE')}"
                                                                pattern="#{constants:get('DATETIME_FORMAT')}"
                                                                readonlyInput="true"/>
                                                    <span>— </span>
                                                    <p:calendar id="todoTaskProcessInitialEndTime"
                                                                value="#{xhhBillWorkbenchBean.todoTaskSearchRequest.processInitialEndTime}"
                                                                styleClass="autoWidthCalendar"
                                                                locale="#{constants:get('LOCALE')}"
                                                                timeZone="#{constants:get('TIME_ZONE')}"
                                                                pattern="#{constants:get('DATETIME_FORMAT')}"
                                                                readonlyInput="true"/>
                                                </p:outputPanel>
                                            </p:panelGrid>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <p:dataTable id="workflowTodoTaskDataTable"
                                         value="#{xhhBillWorkbenchBean.todoTaskLazyDataModel}"
                                         style="width: 100%;"
                                         var="task"
                                         rows="10"
                                         lazy="true"
                                         paginator="true"
                                         paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                                         rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                                         emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                                         reflow="true"
                                         resizableColumns="true">

                                <p:column headerText="操作">
                                    <p:splitButton icon="fa fa-desktop"
                                                   action="#{xhhBillWorkbenchBean.onHandleWorkflow(task.id)}"
                                                   process="@this">
                                        <f:setPropertyActionListener
                                                value="/views/settlementsystem/bill/bill-workbench.xhtml"
                                                target="#{currentUserBean.back}"/>
                                        <p:menuitem value="流程跟踪" icon="fa fa-history"
                                                    process="@this"
                                                    actionListener="#{xhhBillWorkbenchBean.onLoadProcessTracking(task.procInstId)}"
                                                    update=":workbenchForm:workflowTrackingComponent:workflowTrackingDialog"
                                                    oncomplete="PF('workflowTrackingDialogWidgetVar').show();">
                                            <f:setPropertyActionListener value="#{task.procInstId}"
                                                                         target="#{xhhBillWorkbenchBean.procInstId}"/>
                                        </p:menuitem>
                                    </p:splitButton>
                                </p:column>
                                <p:column headerText="流程名称">
                                    <h:outputText value="#{task.procDefName}" style="font-weight:bold; color: #0388e5"
                                                  rendered="#{!task.hasReadLog}"/>

                                    <h:outputText value="#{task.procDefName}" rendered="#{task.hasReadLog}"/>
                                </p:column>
                                <p:column headerText="开票主体" style="width: 200px">
                                    <h:outputText value="#{xhhBillWorkbenchBean.companyName(task.id)}"/>
                                </p:column>
                                <p:column headerText="开票金额" >
                                    <h:outputText value="#{xhhBillWorkbenchBean.amount(task.id)}"/>
                                </p:column>
                                <p:column headerText="流程标题" style="width:300px;">
                                    <h:outputText value="#{task.procInstName}" style="font-weight:bold; color: #0388e5"
                                                  rendered="#{!task.hasReadLog}"/>

                                    <h:outputText value="#{task.procInstName}" rendered="#{task.hasReadLog}"/>
                                </p:column>
                                <p:column headerText="当前环节">
                                    <h:outputText value="#{task.taskName}" style="font-weight:bold; color: #0388e5"
                                                  rendered="#{!task.hasReadLog}"/>

                                    <h:outputText value="#{task.taskName}" rendered="#{task.hasReadLog}"/>
                                </p:column>
                                <p:column headerText="申请人">
                                    <h:outputText value="#{task.startUserName}" style="font-weight:bold; color: #0388e5"
                                                  rendered="#{!task.hasReadLog}"/>

                                    <h:outputText value="#{task.startUserName}" rendered="#{task.hasReadLog}"/>
                                </p:column>
                                <p:column headerText="流程类型">
                                    <h:outputText
                                            value="#{xhhBillWorkbenchBean.translate(DictionaryCode.WORKFLOW_CATEGORY,task.category)}"
                                            style="font-weight:bold; color: #0388e5" rendered="#{!task.hasReadLog}"/>

                                    <h:outputText
                                            value="#{xhhBillWorkbenchBean.translate(DictionaryCode.WORKFLOW_CATEGORY,task.category)}"
                                            rendered="#{task.hasReadLog}"/>
                                </p:column>
                                <p:column headerText="流程发起时间">
                                    <h:outputText value="#{task.procInstStartTime}"
                                                  style="font-weight:bold; color: #0388e5"
                                                  rendered="#{!task.hasReadLog}">
                                        <f:convertDateTime pattern="#{constants:get('DATETIME_FORMAT')}"/>
                                    </h:outputText>

                                    <h:outputText value="#{task.procInstStartTime}" rendered="#{task.hasReadLog}">
                                        <f:convertDateTime pattern="#{constants:get('DATETIME_FORMAT')}"/>
                                    </h:outputText>
                                </p:column>

                                <p:column headerText="环节开始时间">
                                    <h:outputText value="#{task.taskStartTime}" style="font-weight:bold; color: #0388e5"
                                                  rendered="#{!task.hasReadLog}">
                                        <f:convertDateTime pattern="#{constants:get('DATETIME_FORMAT')}"/>
                                    </h:outputText>

                                    <h:outputText value="#{task.taskStartTime}" rendered="#{task.hasReadLog}">
                                        <f:convertDateTime pattern="#{constants:get('DATETIME_FORMAT')}"/>
                                    </h:outputText>
                                </p:column>
                            </p:dataTable>
                        </p:tab>
                        <p:tab title="个人已办任务">
                            <div class="workbench-topbar clearfix"
                                 style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                                <p:toolbar>
                                    <f:facet name="right">
                                        <p:commandButton value="查询" icon="fa fa-search"
                                                         update="workflowDoneTaskDataTable"/>
                                        <p:commandButton value="重置" icon="fa fa-refresh"
                                                         actionListener="#{xhhBillWorkbenchBean.onResetDoneTask}"
                                                         process="@this"
                                                         update="doneTaskCategory doneTaskProcInstName doneTaskProcessInitialStartTime doneTaskProcessInitialEndTime"/>
                                    </f:facet>
                                </p:toolbar>
                            </div>
                            <div class="ui-fluid" style="padding-top: 40px;">
                                <div class="ui-g">
                                    <div class="ui-g-12">
                                        <div class="card ui-g-12">
                                            <p:panelGrid columns="4" layout="grid"
                                                         columnClasses="ui-grid-col-1,ui-grid-col-5,ui-grid-col-1,ui-grid-col-5"
                                                         styleClass="ui-panelgrid-blank"
                                                         style="border:0px none; background-color:transparent;text-align:center;">
                                                <p:outputLabel value="流程类型"/>
                                                <p:selectOneMenu id="doneTaskCategory"
                                                                 value="#{xhhBillWorkbenchBean.doneTaskSearchRequest.category}"
                                                                 filter="true"
                                                                 filterMatchMode="contains">
                                                    <f:selectItem itemLabel="请选择" itemValue=""
                                                                  noSelectionOption="true"/>
                                                    <f:selectItems
                                                            value="#{xhhBillWorkbenchBean.dictionaries[DictionaryCode.WORKFLOW_CATEGORY]}"
                                                            var="dic"
                                                            itemLabel="#{dic.name}" itemValue="#{dic.value1}"/>
                                                </p:selectOneMenu>

                                                <p:outputLabel value="流程标题"/>
                                                <p:inputText id="doneTaskProcInstName"
                                                             value="#{xhhBillWorkbenchBean.doneTaskSearchRequest.procInstName}"/>

                                                <p:outputLabel value="流程发起时间"/>
                                                <p:outputPanel>
                                                    <p:calendar id="doneTaskProcessInitialStartTime"
                                                                value="#{xhhBillWorkbenchBean.doneTaskSearchRequest.processInitialStartTime}"
                                                                styleClass="autoWidthCalendar"
                                                                locale="#{constants:get('LOCALE')}"
                                                                timeZone="#{constants:get('TIME_ZONE')}"
                                                                pattern="#{constants:get('DATETIME_FORMAT')}"
                                                                readonlyInput="true"/>
                                                    <span>— </span>
                                                    <p:calendar id="doneTaskProcessInitialEndTime"
                                                                value="#{xhhBillWorkbenchBean.doneTaskSearchRequest.processInitialEndTime}"
                                                                styleClass="autoWidthCalendar"
                                                                locale="#{constants:get('LOCALE')}"
                                                                timeZone="#{constants:get('TIME_ZONE')}"
                                                                pattern="#{constants:get('DATETIME_FORMAT')}"
                                                                readonlyInput="true"/>
                                                </p:outputPanel>
                                            </p:panelGrid>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <p:dataTable id="workflowDoneTaskDataTable"
                                         value="#{xhhBillWorkbenchBean.doneTaskLazyDataModel}"
                                         style="width: 100%"
                                         var="task"
                                         rows="10"
                                         lazy="true"
                                         paginator="true"
                                         paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                                         rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                                         emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                                         reflow="true"
                                         resizableColumns="true">

                                <p:column headerText="操作">
                                    <p:splitButton icon="fa fa-eye" process="@this"
                                                   actionListener="#{xhhBillWorkbenchBean.onLoadProcessTracking(task.procInstId)}"
                                                   update=":workbenchForm:workflowTrackingComponent:workflowTrackingDialog"
                                                   oncomplete="PF('workflowTrackingDialogWidgetVar').show();">
                                        <f:setPropertyActionListener value="#{task.procInstId}"
                                                                     target="#{xhhBillWorkbenchBean.procInstId}"/>
                                    </p:splitButton>
                                </p:column>
                                <p:column headerText="流程类型">
                                    <h:outputText
                                            value="#{xhhBillWorkbenchBean.translate(DictionaryCode.WORKFLOW_CATEGORY,task.category)}"/>
                                </p:column>
                                <p:column headerText="流程名称">
                                    <h:outputText value="#{task.procDefName}"/>
                                </p:column>
                                <p:column headerText="流程标题">
                                    <h:outputText value="#{task.procInstName}"/>
                                </p:column>
                                <p:column headerText="当前环节">
                                    <h:outputText value="#{task.taskName}"/>
                                </p:column>
                                <p:column headerText="申请人">
                                    <h:outputText value="#{task.startUserName}"/>
                                </p:column>
                                <p:column headerText="流程发起时间">
                                    <h:outputText value="#{task.procInstStartTime}">
                                        <f:convertDateTime pattern="#{constants:get('DATETIME_FORMAT')}"/>
                                    </h:outputText>
                                </p:column>
                                <p:column headerText="环节开始时间">
                                    <h:outputText value="#{task.taskStartTime}">
                                        <f:convertDateTime pattern="#{constants:get('DATETIME_FORMAT')}"/>
                                    </h:outputText>
                                </p:column>
                                <p:column headerText="环节结束时间">
                                    <h:outputText value="#{task.taskEndTime}">
                                        <f:convertDateTime pattern="#{constants:get('DATETIME_FORMAT')}"/>
                                    </h:outputText>
                                </p:column>
                                <p:column headerText="耗时">
                                    <h:outputText value="#{task.taskDurationDisplay}"/>
                                </p:column>
                            </p:dataTable>
                        </p:tab>
                        <p:tab title="流程申请">
                            <div class="workbench-topbar clearfix"
                                 style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                                <p:toolbar>
                                    <f:facet name="right">
                                        <p:commandButton value="查询" icon="fa fa-search"
                                                         update="workflowStartableDataTable"/>
                                        <p:commandButton value="重置" icon="fa fa-refresh"
                                                         actionListener="#{xhhBillWorkbenchBean.onResetStartableWorkflow}"
                                                         process="@this"
                                                         update="startableCategory startableProcDefName"/>
                                    </f:facet>
                                </p:toolbar>
                            </div>
                            <div class="ui-fluid" style="padding-top: 40px;">
                                <div class="ui-g">
                                    <div class="ui-g-12">
                                        <div class="card ui-g-12">
                                            <p:panelGrid columns="4" layout="grid"
                                                         columnClasses="ui-grid-col-1,ui-grid-col-5,ui-grid-col-1,ui-grid-col-5"
                                                         styleClass="ui-panelgrid-blank"
                                                         style="border:0px none; background-color:transparent;text-align:center;">
                                                <p:outputLabel value="流程类型"/>
                                                <p:selectOneMenu id="startableCategory"
                                                                 value="#{xhhBillWorkbenchBean.startableWorkflowSearchRequest.category}"
                                                                 filter="true"
                                                                 filterMatchMode="contains">
                                                    <f:selectItem itemLabel="请选择" itemValue=""
                                                                  noSelectionOption="true"/>
                                                    <f:selectItems
                                                            value="#{xhhBillWorkbenchBean.dictionaries[DictionaryCode.WORKFLOW_CATEGORY]}"
                                                            var="dic"
                                                            itemLabel="#{dic.name}" itemValue="#{dic.value1}"/>
                                                </p:selectOneMenu>

                                                <p:outputLabel value="流程名称"/>
                                                <p:inputText
                                                        id="startableProcDefName"
                                                        value="#{xhhBillWorkbenchBean.startableWorkflowSearchRequest.procDefName}"/>
                                            </p:panelGrid>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <p:dataTable id="workflowStartableDataTable"
                                         value="#{xhhBillWorkbenchBean.startableWorkflowLazyDataModel}"
                                         style="width: 100%;"
                                         var="processDefinition"
                                         rows="10"
                                         lazy="true"
                                         paginator="true"
                                         paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                                         rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                                         emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                                         reflow="true"
                                         resizableColumns="true">

                                <p:column headerText="操作" width="10%">
                                    <p:splitButton icon="fa fa-play-circle"
                                                   action="#{xhhBillWorkbenchBean.onGoToStartPageUrl(processDefinition.startPageUrl)}"
                                                   process="@this">
                                        <f:setPropertyActionListener
                                                value="/views/workbench.xhtml"
                                                target="#{currentUserBean.back}"/>
                                        <p:menuitem value="流程图" icon="fa fa-history"
                                                    process="@this"
                                                    oncomplete="PF('workflowImageWidgetVar').show()"
                                                    update=":workbenchForm:workflowProcessImageComponent:workflowImageDialog">
                                            <f:setPropertyActionListener value="#{processDefinition.deploymentId}"
                                                                         target="#{xhhBillWorkbenchBean.deploymentId}"/>
                                        </p:menuitem>
                                    </p:splitButton>
                                </p:column>
                                <p:column headerText="流程类型" width="10%">
                                    <h:outputText
                                            value="#{xhhBillWorkbenchBean.translate(DictionaryCode.WORKFLOW_CATEGORY,processDefinition.category)}"/>
                                </p:column>
                                <p:column headerText="流程名称">
                                    <h:outputText value="#{processDefinition.name}"/>
                                </p:column>
                            </p:dataTable>
                        </p:tab>
                    </p:tabView>
                </div>
            </div>
            <component:workflow-process-image id="workflowProcessImageComponent"
                                              deploymentId="#{xhhBillWorkbenchBean.deploymentId}"/>
            <component:workflow-tracking procInstId="#{xhhBillWorkbenchBean.procInstId}"
                                         trackingResponses="#{xhhBillWorkbenchBean.trackingResponses}"
                                         id="workflowTrackingComponent"/>
        </h:form>
    </ui:define>
</ui:composition>